<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>流转统计（检查）</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
</head>
<body>
<div class="cqyj_table_div">
    <form class="layui-form" method="post" id="form">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="text" readonly class="layui-input" id="lasjTime" placeholder="创建时间">
            </div>
            			            
            <div class="layui-input-inline">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="demo">查询</button>
            </div>
    	</div>
    	
    	<table class="layui-hide" id="ajcx_table" lay-filter="ajcx_table"></table>
    </form>
    
    <form class="layui-form" method="post" id="form1" hidden="true">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <div onclick="returnPage()" class="layui-btn">返回</div>
            </div>
    	</div>
    	
    	<table class="layui-hide" id="ajcx_table1" lay-filter="ajcx_table1"></table>
    </form>
 
    <form class="layui-form" method="post" id="form2" hidden="true">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <div onclick="returnPage()" class="layui-btn">返回</div>
            </div>
    	</div>
    	
    	<table class="layui-hide" id="flowRecord_table" lay-filter="ajcx_table1"></table>
    </form> 
    
</div>

</body>
<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="ajxxRecord">流转记录</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="logRecord">日志记录</a>
</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-primary" lay-event="returnBack" >返回</button>
    </div>
</script>

<script type="text/html" id="toolbar_log">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-primary" lay-event="returnBack" >返回</button>
    </div>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/layui-ext/selectM/selectM.js"></script>
<script src="/js/core.util.js"></script>
<script language="JavaScript" src="/newmain/js/bizjs/gy.js"></script>
<script>
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var tableIns1;
    var tableIns2;
    
    var ajztDms;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var tree = layui.tree;
    var la_startTime = null;
    var la_endTime = null;
    var zxwb_startTime = null;
    var zxwb_endTime = null;
    var ja_startTime = null;
    var ja_endTime = null;
    var selectMAjcx = layui.selectM;

    layui.config({
        base: '/'       
    }).extend({
        eleTree: 'layui-ext/eleTree/eleTree',
        tableMerge: 'layui-ext/tableMerge/tableMerge'
    }).use(['table', 'laypage', 'layer', 'laydate', 'tree', 'eleTree','tableMerge'], function () {
     	
        tableIns1 = table.render({
            elem: '#ajcx_table'
            , contentType: 'application/json'
            , headers: {"authorization": token}
            // ,where:{statisticsYear:currentYear,statisticsMonth:'0'}
            , url: '/workflow/statistics/inspect' //数据接口
            , method: 'POST',title:'案件统计(检查)',totalRow: true //开启合计行
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data //解析数据列表
                }
            }
            , cols: [
                [
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'jcbmDm',title: '税务机关代码',align:'center',rowspan:2,hide:true},
                    {field: 'jcswjg',title: '税务机关',align:'center',rowspan:2,totalRowText: '合计：'},
                    {title: '检查科长',align:'center',colspan: 4},
                    {title: '主管局长',align:'center',colspan: 4},
                    {title: '送审理',align:'center',colspan: 3},
                ],
                [

                    {field: 'ypJckz', title: '应批', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'ypJckz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    ,{field: 'dpJckz', title: '待批', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'dpJckz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    ,{field: 'tjJckz', title: '通过', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'tjJckz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    ,{field: 'jjJckz', title: '拒绝', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'jjJckz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    ,{field: 'ypJz', title: '应批', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'ypJz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    ,{field: 'dpJz', title: '待批', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'dpJz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    ,{field: 'tgJz', title: '通过', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'tgJz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    ,{field: 'jjJz', title: '拒绝', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'jjJz',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    
                    ,{field: 'sslSs', title: '送审', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'sslSs',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    
                    ,{field: 'sslTg', title: '通过', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'sslTg',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}
                    
                    ,{field: 'sslJj', title: '拒绝', align:'center',style : 'cursor:pointer;text-decoration:underline',
						event: 'sslJj',
						totalRow: '{{parseInt(d.TOTAL_NUMS)}}'}

                ]
            ]
            // ,toolbar: '#toolbar'
            ,done: function(res, curr, count){
       	     	 var divArr = $(".layui-table-total div.layui-table-cell");
	       	     $.each(divArr,function (index,item) {
	       	         var _div = $(item);
	       	         var content = _div.html();
	       	         content = content.replace(".00","");
	       	         _div.html(content);
	       	     });
       	 	}
        });    	
        
        table.on('tool(ajcx_table)', function (obj) {
			 let event = obj.event;
			 var swryDm = obj.data.jcbmDm;
			 if (event === "ypJckz"){
				var ypJckz = obj.data.ypJckz;
				if(ypJckz == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
				 
			 }else if(event === "dpJckz"){
				var zzjcsl = obj.data.dpJckz;
				if(zzjcsl == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
				
			 }else if(event === "tjJckz"){
				var tjJckz = obj.data.tjJckz;
				if(tjJckz == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
			 }else if(event === "jjJckz"){
				var jjJckz = obj.data.jjJckz;
				if(jjJckz == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
					
			 }else if(event === "ypJz"){
				var ypJz = obj.data.ypJz;
				if(ypJz == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
			 }else if(event === "dpJz"){
				var dpJz = obj.data.dpJz;
				if(dpJz == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
					
			 }else if(event === "tgJz"){
				var tgJz = obj.data.tgJz;
				if(tgJz == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
			 }else if(event === "jjJz"){
				var jjJz = obj.data.jjJz;
				if(jjJz == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
			 }else if(event === "sslSs"){
				var sslSs = obj.data.sslSs;
				if(sslSs == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
			 }else if(event === "sslTg"){
				var sslTg = obj.data.sslTg;
				if(sslTg == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
					
			 }else if(event === "sslJj"){
				var sslJj = obj.data.sslJj;
				if(sslJj == "0"){
					layer.msg("当前选中数量为0！");
				}else{
					// 执行查询
					search(event,swryDm);
				}
			 }
		});
        
        tableIns2 = table.render({
			elem : '#ajcx_table1',
			contentType : 'application/json',
			headers : {
				"authorization" : token
			}
			//,page : true // 开启分页
			,
			url : '/workflow/statistics/inspectHearDetail' //数据接口
			,
			method : 'POST',
			parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code" : res.code, //解析接口状态
					"msg" : res.msg, //解析提示文本
					"count" : CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
					"data" : CoreUtil.isEmpty(res.data) ? null
							// : CoreUtil.paramsDecrypt(res.data.records)
							: CoreUtil.paramsDecrypt(res.data)
				}
			},
			cols : [ [
{field: 'jcajbh', title: '案件编号', width: 200},
{field: 'nsrmc', title: '纳税人名称', width: 200},
{field: 'nsrsbh', title: '纳税人识别号', width: 200},
{field: 'lats', title: '立案天数', width: 100},
{field: 'larq', title: '立案日期', width: 150},
{field: 'jarq', title: '结案日期', width: 150},
{field: 'jcswjg', title: '所在科室', width: 100},
{field: 'ajztmc', title: '案件状态', width: 100},
{field: 'zsztmc', title: '助手状态', width: 100},
{field: 'jcry', title: '检查人员', width: 200},
{field: 'jcdjrq', title: '检查登记日期', width: 150},
{field: 'jcjsrq', title: '检查结束日期', width: 150},
{field: 'slry', title: '审理人员', width: 200},
{field: 'sldjrq', title: '审理登记日期', width: 150},
{field: 'sljsrq', title: '审理结束日期', width: 150},
{field: 'zxry', title: '执行人员', width: 200},
{field: 'zxdjrq', title: '执行登记日期', width: 150},
{field: 'zxwbrq', title: '执行完毕日期', width: 150},
{field: 'cbse', title: '查补额', width: 150},
{field: 'rkse', title: '入库额', width: 150},
{field: 'ts', title: '案源数量', width: 150},
{toolbar : "#tool", title: '操作', width: 180},

			] ],
		});
		
        laydate.render({
            elem: '#lasjTime'
            , type: 'date'
            , range: '~'
            , done: function (value, date, endDate) {
                if (value != null && value != undefined && value != "") {
                    la_startTime = value.split("~")[0];
                    la_endTime = value.split("~")[1];
                } else {
                    la_startTime = null;
                    la_endTime = null;
                }

            }
        });

        table.on('tool(ajcx_table1)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'ajxxRecord':
                    //加载flowrecord
                    table.render({
                        elem: '#flowRecord_table'
                        , contentType: 'application/json'
                        , headers: {"authorization": token}
                        , where: {relevance:data.jcajxxuuid}
                        , url: '/attention/attentionCase/flowRecord' //数据接口
                        , method: 'POST'
                        , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                            return {
                                "code": res.code, //解析接口状态
                                "msg": res.msg, //解析提示文本
                                "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                                "data": CoreUtil.isEmpty(res.data) ? null : res.data //解析数据列表
                            }
                        }
                        , cols: [
                            [
                                {field: 'category', title: '类型', width: 250,align : 'center'},
                                {field: 'date', title: '日期', width: 120,align : 'center'},
                                {field: 'czr', title: '操作人', width: 140,align : 'center'},
                                {field: 'ajbh', title: '案件编号', width: 200,align : 'center'},
                                {field: 'nsrmc', title: '企业名称', width: 250,align : 'center'},
                                {field: 'czsj', title: '操作时间', width: 120,align : 'center'},
                                {field: 'bz', title: '内容', width: 250,align : 'center'},

                            ]
                        ]
                        // , toolbar: '#toolbar'
                    });
                    
                    // 处理显示隐藏
                    
                    $("#form2").show();
    				$("#form1").hide();
    				$("#form").hide();
    	
                    break;
                case 'logRecord':
                    //日志记录
                    //加载flowrecord
                    skipOpen("/index/statistics/ajlogrecord?relevance=" + data.jcajxxuuid, "11001", "日志记录");
                    break;
            }
        });
        
        
        //执行查询
        form.on('submit(demo)',function(data){
            
            var whereParams = {
                "createStart":la_startTime,
                "createEnd":la_endTime,
            };
            
            tableIns1.reload({
                where :whereParams
            },false);
        })
    });

   	
    function search(mark,swryDm){
    	$("#form").hide();
    	$("#form1").show();
    	$("#form2").hide();
    	
    	var whereParams = {
			"createStart":la_startTime,
			"createEnd":la_endTime,
			"mark":mark,
			"taxorgcode":swryDm
		};
    	
		tableIns2.reload({
			where :whereParams
		},false);
    	
    }
    
    function returnPage(){
    	$("#form1").hide();
    	$("#form").show();
    	$("#form2").hide();
    	
    }
    
    function getCurrentDay(){
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        month = (month > 9) ? month : ("0" + month);
        day = (day < 10) ? ("0" + day) : day;
        var today = year + "-" + month + "-" + day;
        return today;
    }


</script>
</html>